export default {
    count(state){
        return state.cartList.length;
    },

    goodsList(state) {
        return state.cartList
    },
    select(state) {
        return state.selectAll
    },
    allPrice(state) {
        // return state.cartList.reduce((total,item) => {
        //     if(item.check) {
        //         console.log(total)
        //         return total + item.price * item.count;
                
        //     }
        // },0)
        let money = 0;
        state.cartList.forEach(item => {
            if(item.check) {
                money+=(item.price*item.count)
            }
        })
        return money.toFixed(2);
    },
    choseCount(state) {
        let count = 0;
        state.cartList.forEach(item => {
            if(item.check) {
                count += item.count;
            }

        })
        return count;
    }


    // checked(state,id) {
    //     let obj = state.cartList.find(item => {
    //         return item.iid == id;
    //     })
    //     console.log(obj)
    //     return obj.check;
    // }
}